#include <cstdio>

#include "yaz.h"

int main()
{
  constexpr int COMPRESSION_LEVEL = 9;
  const char *outfile = "demo-out.zip";

  FILE *out = fopen(outfile, "wb");
  yaz::Encoder zipper(COMPRESSION_LEVEL, [out](std::string_view sv){
    return fwrite(sv.data(), 1, sv.size(), out) == sv.size();  
  });

  // files to zip
  zipper.AddFile("demo-helper/", yaz::MemoryByteSource(""));
  zipper.AddFile("demo-helper/01.txt", yaz::FileByteSource("demo-helper/01.txt"));
  zipper.AddFile("demo-helper/02.txt", yaz::FileByteSource("demo-helper/02.txt"));
  zipper.AddFile("demo-helper/03.txt", yaz::FileByteSource("demo-helper/03.txt"));
  zipper.AddFile("demo-helper/ref.pdf", yaz::FileByteSource("demo-helper/ref.pdf"));
  zipper.AddFile("demo-helper/READMD.md", yaz::MemoryByteSource("This is generated by yaz\n"));
  zipper.Finish();

  fclose(out);
  fprintf(stderr, "Wrote %s\n", outfile);

  return 0;
}
